package com.ruoyi.hr.controller.hr.changemanage;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.Ztree;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.hr.service.entryexitmanage.EntryExitManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @author zeo
 * @explain 入离职管理
 * @date 2020/2/27
 */
@Controller
@RequestMapping("/changeManage")
public class ChangeManageController extends BaseController {

    @Autowired
    EntryExitManageService entryExitManageService;

    private String prefix = "hr/changemanage";

    /**
     * 跳转分页页面
     */
    @GetMapping()
    public String changeManage() {
        return prefix + "/changeManage";
    }

    /**
     * 欢迎
     */
    @GetMapping("/welcome")
    public String welcome() {
        return prefix + "/welcome";
    }

    /**
     * 加载薪资管理左侧树状
     */
    @GetMapping("/treeData")
    @ResponseBody
    public List<Ztree> treeData() {
        List<Ztree> ztrees = new ArrayList<Ztree>();
        Ztree ztree[] = {
                new Ztree((long) 100, (long) 0, "实习管理", "实习管理"),
                new Ztree((long) 101, (long) 100, "实习期变动", "实习期变动"),
                new Ztree((long) 102, (long) 101, "实习期变动登记", "实习期变动登记"),
                new Ztree((long) 103, (long) 101, "实习期变动历史", "实习期变动历史"),
                new Ztree((long) 104, (long) 100, "实习转正", "实习转正"),
                new Ztree((long) 105, (long) 104, "实习转正登记", "实习转正登记"),
                new Ztree((long) 106, (long) 104, "实习转正历史", "实习转正历史"),

                new Ztree((long) 107, (long) 0, "试用期管理", "试用期管理"),
                new Ztree((long) 108, (long) 107, "试用期变动", "试用期变动"),
                new Ztree((long) 109, (long) 108, "试用期变动登记", "试用期变动登记"),
                new Ztree((long) 110, (long) 108, "试用期变动历史", "试用期变动历史"),
                new Ztree((long) 111, (long) 107, "试用转正", "试用转正"),
                new Ztree((long) 112, (long) 111, "试用转正登记", "试用转正登记"),
                new Ztree((long) 113, (long) 111, "试用转正历史", "试用转正历史"),

                new Ztree((long) 114, (long) 0, "人事调动管理", "人事调动管理"),
                new Ztree((long) 115, (long) 114, "部门调动登记", "部门调动登记"),
                new Ztree((long) 116, (long) 114, "人事调用管理历史", "人事调用管理历史"),

                new Ztree((long) 117, (long) 0, "属性变更管理", "属性变更管理"),
                new Ztree((long) 118, (long) 117, "员工属性变更登记", "员工属性变更登记"),
                new Ztree((long) 119, (long) 117, "员工属性变更历史", "员工属性变更历史"),

                new Ztree((long) 120, (long) 0, "员工兼任管理", "员工兼任管理"),
                new Ztree((long) 121, (long) 120, "员工兼任信息查看", "员工兼任信息查看"),
                new Ztree((long) 122, (long) 120, "员工兼任登记", "员工兼任登记"),
                new Ztree((long) 123, (long) 120, "兼任终止登记", "兼任终止登记"),
                new Ztree((long) 124, (long) 120, "兼任管理历史", "兼任管理历史"),

                new Ztree((long) 125, (long) 0, "员工虚拟组织管理", "员工虚拟组织管理"),
                new Ztree((long) 126, (long) 125, "员工加入虚拟组织", "员工加入虚拟组织"),
                new Ztree((long) 127, (long) 125, "员工退出虚拟组织", "员工退出虚拟组织"),
                new Ztree((long) 128, (long) 125, "员工虚拟组织管理历史", "员工虚拟组织管理历史"),
        };
        for (int i = 0; i < ztree.length; i++) {
            ztrees.add(ztree[i]);
        }
        return ztrees;
    }

    @RequestMapping("/getEmpList")
    @ResponseBody
    public TableDataInfo getEmpList(@RequestParam Map map){
        startPage();
        List<Map<String,Object>> list = entryExitManageService.getEmpList(map);
        return getDataTable(list);
    }

}
